package com.elaine.constant;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * @author wrb
 * @date 2020/3/31 14:39
 */
public enum AlapiConstant {

	// 通过中文或数字获取对应api
	ERROR(0, "错误情况","text"),
	DOG(1,"舔狗日记","text"),
	QINGHUA(2,"土味情话","text"),
	SOUL(3,"心灵毒鸡汤","text"),
	HITOKOTO(4,"Hitokoto 一言","text"),
	COMMENT(5,"网易云乐评","text"),
	MINGYAN(6,"名人名言","text"),
	SHICI(7,"随机诗词","text"),
	BING(8,"必应美图","image"),
	ACG(9,"ACG图片","image");

	private int code;

	private String words;

	private String message;

	AlapiConstant(int code, String words,String message) {
		this.code = code;
		this.words = words;
		this.message = message;
	}

	public int getCode() {
		return code;
	}

	public String getWords() {
		return words;
	}

	public String getMessage() {
		return message;
	}

	public static AlapiConstant getAlapiConstant(String value) {
		return Arrays.stream(values()).filter(alapiConstant -> alapiConstant.getWords().equals(value) || String.valueOf(alapiConstant.getCode()).equals(value)).findFirst().orElse(AlapiConstant.ERROR);
	}

	public static String getAlapiConstantContent() {
		return Arrays.stream(values()).filter(alapiConstant -> alapiConstant.getCode() != 0).map(alapiConstant -> alapiConstant.getCode() + " : " + alapiConstant.getWords() + "\n").collect(Collectors.joining("", "功能菜单如下：\n", "\n请输入序号或者文字获取您想要的功能"));
	}

}
